package com.xiaoxi.visitormode.composite;

import com.xiaoxi.visitormode.visitor.Visitor;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.visitormode
 * @ClassName AbstractEntry
 * @Description TODO
 * @Date 2023/3/16 15:50
 * @Version 1.0
 */
public abstract class AbstractEntry extends Entry {

    @Override
    public void add(Entry entry) throws FileNotAddException {
        throw new FileNotAddException("文件不可再往里面添加目录条目", "A100");
    }

    @Override
    public final String pwd() {
        StringBuilder sb = new StringBuilder();
        Entry entry = this;
        while (entry != null) {
            sb.insert(0, "/" + entry.getName());
            entry = entry.parent;
        }
        return sb.toString();
    }


}
